<template>
	<view>
		<xl-navbar title="测试"></xl-navbar>
		
		<swiper class="swiper">
			<swiper-item>
				<view class="swiper-item" @click="open">A</view>
				<xl-popup v-model="show2" direction="bottom" :borderRadius="[20,20,0,0]" background="#0a93ff">
					<view class="box" style="color: #ffffff;">Popup 弹出层</view>
				</xl-popup>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">B</view>
			</swiper-item>
		</swiper>
		<xl-button text="星洛格式" @click="handleAddress('xl')"></xl-button>
		<xl-button text="京东格式" @click="handleAddress('js')"></xl-button>
		<xl-button text="淘宝格式" @click="handleAddress('tb')"></xl-button>
		<xl-button text="拼多多格式" @click="handleAddress('pdd')"></xl-button>
		
		<view>
			{{addressText}}
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { parseAddress } from '@/uni_modules/xingluo-ui/libs/utils/addressParse.js'
	
	const show2 = ref(false)
	
	function open() {
		show2.value = true
	}
	
	const addressText = ref('')
	function handleAddress(type) {
		let address = ''
		switch(type) {
			case 'jd':
			case 'tb': 
				address = `收件人: Jerry
手机号码: 13388888888
所在地区: 北京北京海淀区
详细地址: 北京北京海淀区颐和园路5号`
			break
			case 'pdd':
				address = `林先生 13388888888 北京市海淀区颐和园路5号`
			break
			default:
				address = `林先生，13388888888，北京市海淀区颐和园路5号`
			break
			
		}
		
		addressText.value = JSON.stringify(parseAddress(address))
	}
</script>

<style lang="scss" scoped>t
	.swiper {
		height: 500rpx;
	}
	.swiper-item {
		display: block;
		height: 500rpx;
		line-height: 300rpx;
		text-align: center;
		background-color: #f00;
	}
	.box{
		margin: 30rpx;
	}
</style>